#include <bits/stdc++.h>
#define endl '\n'
using namespace std;

const int MAXN = 200055;

int a[MAXN], n, b[MAXN], ans;

int getans(){
    int last[2] = {0, 0} ,tot = 0;
    for(int i = 1; i <= n; ++ i){
        if(a[last[b[i]]] == a[i])
            tot += a[i];
        last[b[i]] = i;
    }
    return tot;
}

void dfs(int dep){
    if(dep > n){
        ans = max(ans, getans());
        return;
    }
    b[dep] = 1;
    dfs(dep + 1);
    b[dep] = 0;
    dfs(dep + 1);
}

void solve(){
    cin >> n;
    for(int i = 1; i <= n; ++ i)
        cin >> a[i];

    ans = 0;
    dfs(1);
    cout << ans << endl;
}

signed main(){
    freopen("color.in", "r", stdin);
    freopen("color.out", "w", stdout);
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

    int T;
    cin >> T;
    while(T--) solve();

    return 0;
}